use zmath::Vec3;

use crate::DrawMode;

use super::CommonShape;

impl CommonShape {
    pub fn new() -> Self {
        Self {
            draw_mode: DrawMode::Fill,
            vertices: vec![],
            indices: vec![],
        }
    }

    pub fn from_vertices(vertices: &[f32]) -> Self {
        Self {
            draw_mode: DrawMode::Fill,
            vertices: Vec::from(vertices),
            indices: vec![],
        }
    }

    pub fn add_vertex(&mut self, p: Vec3) {
        self.vertices.push(p.0);
        self.vertices.push(p.1);
        self.vertices.push(p.2);
    }

    pub fn set_indices(&mut self, indices: &[u32]) {
        self.indices.clear();
        self.indices.extend_from_slice(indices);
    }
}